﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Migrator.Entities;
using Migrator.Packets;

namespace Migrator.Services
{
    /// <summary>
    /// An entity that provides services to a Node
    /// </summary>
    public interface IService
    {
        /// <summary>
        /// Updates the service.
        /// </summary>
        void Update();

        /// <summary>
        /// Should this service handle the given packet?
        /// </summary>
        /// <param name="packet">The packet to process</param>
        /// <returns>True if the service is interested in handling the
        /// packet, false otherwise</returns>
        bool Filter(IPPacket packet);

        /// <summary>
        /// Handles the given packet
        /// </summary>
        /// <param name="packet">The packet to handle</param>
        void Handle(IPPacket packet);

        /// <summary>
        /// Configure the service, and enables it.
        /// </summary>
        /// <param name="?">Service parameters</param>
        /// <returns>The configured service</returns>
        IService Configure(params object[] configuration);

        /// <summary>
        /// Checks if the service is enabled or disabled.
        /// Also, enables and the service.
        /// </summary>
        bool Enabled
        {
            get;
            set;
        }

        /// <summary>
        /// The node that uses this service.
        /// </summary>
        Node Client
        {
            get;
        }
    }

    public enum Services
    {
        Advertiser,
        HomeAgent,
        ForeignAgent,
        DHCPServer,
        DHCPClient,
        MobileIPNodeService,
        RouteOptimizationService
    };
}
